import {getMachTypeGetList_V1} from "@/api/api.js"
import {getRotaryMaintainDesc} from "@/api/rotary"
export const MachTypeCreate = {
    data() {
        return{
            machTypeList:[],
            logList:[],
            keepMachCode:"",
            keepState:"",
            keepModal:false,
        }
    },
    methods: {
        getMachTypeList(){
            getMachTypeGetList_V1().then(res=>{
                if(res.code == 200) {
                    this.machTypeList = res.data.list;
                    for (let i in this.machTypeList) {
                        this.machTypeList[i].value = this.machTypeList[i].machTypeId;
                        this.machTypeList[i].label = this.machTypeList[i].machTypeName;
                        delete this.machTypeList[i].pid;
                        delete this.machTypeList[i].machTypeName;
                        for (let j in this.machTypeList[i].children) {
                            this.machTypeList[i].children[j].value = this.machTypeList[i].children[j].machTypeId;
                            this.machTypeList[i].children[j].label = this.machTypeList[i].children[j].machTypeName;
                            delete this.machTypeList[i].children[j].machTypeId;
                            delete this.machTypeList[i].children[j].machTypeName;
                        }
                    }
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        getDes(id){
            let params ={
                maintainId:id,
            }
            getRotaryMaintainDesc(params).then(res=>{
                if(res.code == 200) {
                   this.logList = res.data.logList;
                   this.logList.forEach(v=>{
                       if(v.opDetail.length>10){
                            v.opDetailVal = v.opDetail.slice(1,10)+'....'
                       }else{
                        v.opDetailVal = v.opDetail
                       }
                   })
                   this.keepMachCode =res.data.machCode;
                   this.keepState = res.data.state;
                   this.keepModal = true;
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
    }
}